package com.jl15988.chainlog.util;

import java.io.PrintWriter;
import java.io.StringWriter;

/**
 * 异常工具
 *
 * @author Jalon
 * @since 2025/9/30 14:51
 **/
public class ExceptionUtil {

    /**
     * 获取异常堆栈信息
     *
     * @param throwable 异常
     * @return 异常信息
     */
    public static String getExceptionStackTrace(Throwable throwable) {
        if (throwable == null) {
            return null;
        }
        StringWriter sw = new StringWriter();
        PrintWriter pw = new PrintWriter(sw);
        throwable.printStackTrace(pw);
        return sw.toString();
    }
}
